#define _CRT_SECURE_NO_WARNINGS

class Solution {
public:
    vector<int> twoSum(vector<int>& price, int target) {
        vector<int> ret;

        int n = price.size();
        int left = 0, right = n - 1;
        while (left < right)
        {
            int sum = price[left] + price[right];
            if (sum == target)
            {
                ret.push_back(price[left]);
                ret.push_back(price[right]);

                break;
            }
            else if (sum > target)
                right--;
            else
                left++;
        }

        return ret;
    }
};